﻿using System.Collections.Generic;

namespace SocketCore.Encoder
{
    public class MessageEncoderFactory
    {
        private Dictionary<int, IMessageEncoder> encoders = new Dictionary<int, IMessageEncoder>(5);
        private static MessageEncoderFactory instance = new MessageEncoderFactory();

        private MessageEncoderFactory()
        {
            encoders.Add(0, new ManualMessageEncoder());
        }

        public static MessageEncoderFactory Instance
        {
            get { return instance; }
        }

        public IMessageEncoder GetMessageEncoder(int type)
        {
            return encoders[type];
        }

        public void RegisterMessageEncoder(int type, IMessageEncoder encoder)
        {
            encoders.Add(type, encoder);
        }
    }

 

}
